﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Web.Enhancements.Rest;
using System.Runtime.Serialization;

namespace TestWeb25.Components
{
    public class UserExperienceHandler : IWebRestService
    {
        public UserExperienceHandler()
        {
        }

        [WebRestMethodAttribute(false, ContentType = "image/gif")]
        public byte[] GetSubjectImage(string subjectCode)
        {
            byte[] bytes = System.IO.File.ReadAllBytes(HttpContext.Current.Server.MapPath(string.Format("Content/Images/{0}.gif", subjectCode)));
            return bytes;
        }

        [WebRestMethodAttribute(false, ContentType = "application/pdf")]
        public byte[] ServeDocumentation(string documentName)
        {
            byte[] bytes = System.IO.File.ReadAllBytes(HttpContext.Current.Server.MapPath(string.Format("Content/{0}.pdf", documentName)));
            return bytes;
        }

        [WebRestMethodAttribute(ContentType = "application/json")]
        public Employee RetrieveEmployeeInfo(int userId)
        {
            Employee emp = new Employee()
            {
                FirstName = "Mark",
                LastName = "Jason",
                UserName = "Jasonman",
                UserId = userId
            };
            return emp;
        }

        [WebRestMethodAttribute(ContentType = "application/json", JsonSerializer = JsonSerializerType.DataContractJsonSerializer)]
        public Employee RetrieveEmployeeInfo2(int userId)
        {
            Employee emp = new Employee()
            {
                FirstName = "Mark",
                LastName = "Jason",
                UserName = "Jasonman",
                UserId = userId
            };
            return emp;
        }

    }

    [Serializable()]
    [DataContract]
    public class Employee 
    {
        [DataMember(Name="UserInternalId")]
        public int UserId { get; set; }
        [DataMember(Name="LName")]
        public string LastName { get; set; }
        [DataMember(Name="FName")]
        public string FirstName { get; set; }
        [DataMember(Name="UName")]
        public string UserName { get; set; }

        public Employee()
        {
            this.FirstName = "";
            this.LastName = "";
            this.UserName = "";
        }
    }

}